package com.xf2048.view;

import com.xf2048.global.GameConfig;
import com.xf2048.ui.MainActivity;
import com.xf2048.ui.WelcomeActivity;
import com.zhuifeng.study2048.R;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class LoveModeDialog extends Dialog {

	private Context context = null;
	private Button ensureButton = null;
	private Button cancelButton = null;

	public LoveModeDialog(Context context) {
		super(context, R.style.dialog);
		this.context = context;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		super.setContentView(R.layout.love_mode_dialog_view);

		this.init();
	}

	private void init() {
		this.ensureButton = (Button) findViewById(R.id.love_mode_dialog_view_love_Button);
		this.cancelButton = (Button) findViewById(R.id.love_mode_dialog_view_ribbon_Button);

		this.ensureButton.setOnClickListener(new MyOnClickListener());
		this.cancelButton.setOnClickListener(new MyOnClickListener());

	}

	class MyOnClickListener implements View.OnClickListener {

		@Override
		public void onClick(View v) {
			if (v == ensureButton) {
				GameConfig.playMode = 2;
				Intent intent = new Intent(context, MainActivity.class);
				context.startActivity(intent);
				((WelcomeActivity) context).finish();
				LoveModeDialog.this.dismiss();
			} else if (v == cancelButton) {
				SetCardDialog setCard = new SetCardDialog(context);
				setCard.show();
				setCard.setCanceledOnTouchOutside(false);
				LoveModeDialog.this.dismiss();
			}
		}
	}

}
